// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import EventManager from "./Common/EventManager";
import yyComponent from "./Common/yyComponent";
import { EventType } from "./GameSpecial/GameEventType";
import { sers } from "./frameSccript/system/OverallSystem ";

const {ccclass, property} = cc._decorator;

@ccclass
export default class checkScene extends yyComponent {



    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {

       this.show()

        EventManager.on(EventType.UIEvent.showCheckSceneBtn,()=>{
            if(this && this.node){
                this.show()
            }
        },this)
    }

    show(){
        if(window['tt'] && window['tt'].checkScene && !sers().userSrv.getCheckScene()){
            let that = this
            window['tt'].checkScene({
                scene: "sidebar",
                success: (res) => {
                    console.log("check scene success: ", res.isExist);
                    //成功回调逻辑
                    if(!res.isExist){
                        that.node.parent = null
                    }
                },
                fail: (res) => {
                    console.log("check scene fail:", res);
                    that.node.parent = null
                    //失败回调逻辑
                }
            });
        }else{
            this.node.parent = null
        }
    }

    showCebianlan(){
        sers().uiSrv.showCebianlan()
    }
   



    // update (dt) {}
}
